package com.szq.pattern;

/**
 * @description:
 * @author: szq
 * @date: 2021-09-02 10:43:25
 */
public class MigrantWorker {

    private String name;
    private int age;
    private String telephone;
    private String gender;

    public MigrantWorker() {
    }

    public static MigrantWorker builder() {
        return new MigrantWorker();
    }

    public MigrantWorker name(String name){
        this.name = name;
        return this;
    }

    public MigrantWorker age(int age){
        this.age = age;
        return this;
    }

    public MigrantWorker telephone(String telephone){
        this.telephone = telephone;
        return this;
    }

    public MigrantWorker gender(String gender){
        this.gender = gender;
        return this;
    }

    //执行创建操作
    public MigrantWorker build() {
        validateObject(this);
        return this;
    }

    private void validateObject(MigrantWorker migrantWorker) {
        //可以做基础预校验，或自定义校验
    }
    @Override
    public String toString() {
        return "MigrantWorker{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", telephone='" + telephone + '\'' +
                ", gender='" + gender + '\'' +
                '}';
    }
}
